package cn.edu.scau.cmi.linzhanyi.factory;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.layout.*;

import java.net.URL;
import java.util.Random;
import java.util.ResourceBundle;

public class Controller implements Initializable {

    @FXML
    private ComboBox<String> combox;
    @FXML
    private TextArea showinfotext;
    @FXML
    private Pane pane;
    private String type;
    @FXML
    public void onbutton(){
    	
        pane.setStyle("-fx-background-image: url("+getClass().getResource((new Random().nextInt(2)+2)+""+".jpg")+"); -fx-background-repeat: no-repeat; -fx-background-size: stretch;");
        
        showinfotext.setText(GetFactory.getFactory(type).getInsurance().getIntroduction());

    }
    @FXML
    public void onselect(){
        type=combox.getSelectionModel().getSelectedItem().toString();
    }
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        pane.setStyle("-fx-background-image: url("+getClass().getResource((new Random().nextInt(2)+2)+""+".jpg")+"); -fx-background-repeat: no-repeat; -fx-background-size: stretch;");

        ObservableList<String> options =
                FXCollections.observableArrayList(
                        "驾驶员身体受伤","汽车损坏","人员伤亡","多种事故"
                );

       combox.setItems(options);
       combox.setPromptText("驾驶员身体受伤");
       type = combox.getPromptText();

    }
}
